package com.bysj.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bysj.fenye.pagevo.NewsPageVO;

public class AllNewsServlet extends HttpServlet {
	 private NewsPageVO pagevo=new NewsPageVO(10);
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String m=request.getParameter("m");
		String method=request.getParameter("method");
		if("pre".equals(method)){
			this.pagevo.setPrevious();
			request.getSession().setAttribute("nlist", this.pagevo);
		}else if("next".equals(method)){
			this.pagevo.setNext();
			request.getSession().setAttribute("nlist", this.pagevo);
		}else if("lasts".equals(method)){
			this.pagevo.setLast();
			request.getSession().setAttribute("nlist", this.pagevo);
		}else if("index".equals(method)){
			String ind=request.getParameter("ind");
			this.pagevo.setIndex(Integer.parseInt(ind.trim()));
			request.getSession().setAttribute("nlist", this.pagevo);
		}else{
			this.pagevo.setFirst();
			request.getSession().setAttribute("nlist", this.pagevo);
		}
		if("allnews".equals(m)){
			request.getRequestDispatcher("../moreNews.jsp").forward(request, response);
		}
		
		
	
	}
}
